﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Hangjing.Common;
using Hangjing.Model;
using Hangjing.SQLServerDAL;
using System.Collections.Generic;
using Hangjing.AppLog;

/// <summary>
/// 分享配置
/// </summary>
public partial class Admin_Shop_promotionshareconfig : System.Web.UI.Page
{
    PromotionShareConfigDal dal = new PromotionShareConfigDal();
    protected void Page_Load(object sender, EventArgs e)
    {
        ValidatorSet validator = new ValidatorSet("Admin");
        validator.SetValidator();

        if (!IsPostBack)
        {
            BindFoodData();
        }
    }

    /// <summary>
    /// 获取信息
    /// </summary>
    protected void BindFoodData()
    {
        promotion_share_config info = dal.GetEntity(1);
        if (info != null)
        {
            WebUtility.RadioValue(tbstauts, info.stauts.ToString());
            tbfirst_level_price.Text = info.first_level_price.ToString();
            tbsecond_level_price.Text = info.second_level_price.ToString();
            tbwidthdraw_cach_num.Text = info.widthdraw_cach_num.ToString();
        }
    }

    /// <summary>
    /// 添加，编辑数据
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btSave_Click(object sender, EventArgs e)
    {
        promotion_share_config info = dal.GetEntity(1);
        info.stauts = WebUtility.InputText(tbstauts.SelectedValue,true);
        info.first_level_price = Convert.ToDecimal(tbfirst_level_price.Text);
        info.second_level_price = Convert.ToDecimal(tbsecond_level_price.Text);
        info.widthdraw_cach_num = Convert.ToInt32(tbwidthdraw_cach_num.Text);
        info.u_t = DateTime.Now;
       

        if (dal.Update(info))
        {
            OperationLog.Info("管理员：" + UserHelp.GetAdmin().AdminName + "修改了分享配置");
            AlertScript.RegScript(this, UpdatePanel1, "alert('操作成功.');gourl('promotionshareconfig.aspx');");

        }
        else
        {
            AlertScript.RegScript(this, UpdatePanel1, "showMessage('添加失败','error','true','8');");
        }

    }



}
